package com.myalibaba.example;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.env.Environment;

import java.util.Arrays;

public class EnvironmentExample {

    public static void main(String[] args) {
        ApplicationContext context = new AnnotationConfigApplicationContext(); // 或者其他的 ApplicationContext 实现类

        // 获取 Environment 对象
        Environment environment = context.getEnvironment();

        // 使用 Environment 对象获取活动的配置文件
        String[] activeProfiles = environment.getActiveProfiles();
        System.out.println("Active profiles: " + Arrays.toString(activeProfiles));

        // 其他逻辑...
    }
}
